package com.wc.算法提高课.C第三章_图论.欧拉回路和欧拉路径.欧拉回路;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @Author congge
 * @Date 2024/10/22 10:40
 * @description https://www.acwing.com/problem/content/description/1186/
 */
public class Main {
    /**
     * 思路：欧拉回路, 遍历每一条边, 防止重复遍历, 删边
     */
    static FastReader sc = new FastReader();
    static PrintWriter out = new PrintWriter(System.out);
    static int N = 100010, M = 400010;
    static int[] h = new int[N], e = new int[M], ne = new int[M];
    static int[] din = new int[N], dout = new int[N];
    static int[] ans = new int[M];
    static boolean[] used = new boolean[M];
    static int idx = 1, cnt = 0;
    static int n, m, type;

    public static void main(String[] args) {
        type = sc.nextInt();
        n = sc.nextInt();
        m = sc.nextInt();
        for (int i = 0; i < m; i++) {
            int a = sc.nextInt(), b = sc.nextInt();
            add(a, b);
            if (type == 1) add(b, a);
            din[b]++;
            dout[a]++;
        }
        boolean success = true;
        if (type == 1) {
            for (int i = 1; i <= n; i++) {
                if ((din[i] + dout[i] & 1) == 1) {
                    success = false;
                    break;
                }
            }
        } else {
            for (int i = 1; i <= n; i++) {
                if (din[i] != dout[i]) {
                    success = false;
                    break;
                }
            }
        }
        for (int i = 1; i <= n; i++) {
            if (din[i] != 0) {
                dfs(i);
                break;
            }
        }
        if (cnt < m) {
            success = false;
        }
        if (!success) out.println("NO");
        else {
            out.println("YES");
            for (int i = cnt; i > 0; i--) out.print(ans[i] + " ");
            out.println();
        }
        out.flush();
    }

    static void dfs(int u) {
        for (int i = h[u]; i > 0; i = h[u]) {
            if (used[i]) {
                // 这个是为了删除反向边
                h[u] = ne[i];
                continue;
            }
            used[i] = true;
            int t;
            if (type == 1) {
                t = (i + 1) / 2;
                if (i % 2 == 0) {
                    used[i - 1] = true;
                    t = -t;
                } else used[i + 1] = true;
            } else t = i;
            int j = e[i];
            h[u] = ne[i];
            dfs(j);
            // 需要保证其他的边或者是环经过完毕之后, 才是这个边经过
            ans[++cnt] = t;
        }
    }

    static void add(int a, int b) {
        e[idx] = b;
        ne[idx] = h[a];
        h[a] = idx++;
    }
}


class FastReader {
    StringTokenizer st;
    BufferedReader br;

    FastReader() {
        br = new BufferedReader(new InputStreamReader(System.in));
    }

    String next() {
        while (st == null || !st.hasMoreElements()) {
            try {
                st = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        return st.nextToken();
    }

    int nextInt() {
        return Integer.parseInt(next());
    }

    String nextLine() {
        String s = "";
        try {
            s = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return s;
    }

    long nextLong() {
        return Long.parseLong(next());
    }

    double nextDouble() {
        return Double.parseDouble(next());
    }

    // 是否由下一个
    boolean hasNext() {
        while (st == null || !st.hasMoreTokens()) {
            try {
                String line = br.readLine();
                if (line == null)
                    return false;
                st = new StringTokenizer(line);
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return true;
    }
}
